﻿using CPPEI.Coolzon.UI.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace CPPEI.Coolzon.Designer.Views
{
    public partial class DesignView
    {
        private Coolzon.UI.Part __selectedPart;
        /// <summary>
        /// 选中的组件实例
        /// </summary>
        private Coolzon.UI.Part _selectedPart
        {
            get
            {
                return __selectedPart;
            }
            set
            {
                if(__selectedPart != null)
                {
                    __selectedPart.PropertyChanged -= _selectedPartInstance_PropertyChanged;
                }
                __selectedPart = value;
                if (__selectedPart != null)
                {
                    __selectedPart.PropertyChanged += _selectedPartInstance_PropertyChanged;
                }
            }
        }

        /// <summary>
        /// mouse down point in scene,
        /// 用于组件resize的时候判断位置变动量或者大小变动量
        /// </summary>
        private Point _mdpInScene;
        /// <summary>
        /// mouse down point in canvas
        /// </summary>
        private Point _mdpInCanvas;
        /// <summary>
        /// mouse down point in Container
        /// </summary>
        private Point _mdpInContainer;

        /// <summary>
        /// 当前鼠标所在的位置基于scene
        /// </summary>
        private Point _mpInScene;
        /// <summary>
        /// mouse point in canvas
        /// </summary>
        private Point _mpInCanvas;
        /// <summary>
        /// mouse point in Container
        /// </summary>
        private Point _mpInContainer;

        /// <summary>
        /// design border postiion stored data
        /// </summary>
        private Point _dbPosStore;

        /// <summary>
        /// design border size stored data
        /// </summary>
        private Size _dbSizeStore;

        /// <summary>
        /// is editable,true:can edit, false:can't edit
        /// </summary>
        private bool _isEditable = false;

        /// <summary>
        /// 
        /// </summary>
        private DesignBorderHitResult _designBorderHitResult;

        /// <summary>
        /// 鼠标左键是否处于按下状态
        /// </summary>
        private bool _isMLBDown = false;

        private Coolzon.UI.IPartContainer _layoutPartContainer;


        #region //////////////////////old

        /// <summary>
        /// 组件在移动前的大小信息
        /// </summary>
        private double _oldLeft4PartInstance;
        private double _oldTop4PartInstance;
        private double _oldWidth4PartInstance;
        private double _oldHeight4PartInstance;

        private Point? _pointInCanvas;
        private Point? _pointInFrame;
        private Point? _pointInScene;
        private Point? _pointInPartContainer;

        /// <summary>
        /// 调整大小开始时，鼠标的位置
        /// </summary>
        private Point _mousePointInSceneWhenBeginResize { get; set; }

        /// <summary>
        /// 调整大小开始时，组件的大小
        /// </summary>
        private Size _partSizeWhenBeginResize { get; set; }

        /// <summary>
        /// 调整大小开始时，组件的左上角位置（相对值)
        /// </summary>
        private Point _partPositionWhenBeginResize { get; set; }
        #endregion
    }
}
